package innerclass;
 


public class TestSequence{
	
	public static void main(String[] args) {
		Sequence seq = new Sequence(10);
		for (int i = 0; i < 10; i++) {
			seq.add(i);
		}
//		Selector selector1 = seq.selector();
		Selector selector2 = seq.new SequenceSelector();
		seq.new SequenceSelector();
		
		Sequence.SequenceSelector selector1 = seq.new SequenceSelector();
		while(!selector1.end()){
			System.out.println(selector1.current() + "");
			System.out.println(selector2.current() + "");
			selector1.next();
			selector2.next();
		}
		
//		Sequence.SequenceSelector selector22 = new Sequence.SequenceSelector();
	}
}

 class Sequence {
	
	private Object[] items;
	
	private int next = 0;
	
	public Sequence(int size){
		items = new Object[size];
	}
	
	public void add(Object x){
		if(next < items.length){
			items[next++] = x;
		}
	}
	
	public class SequenceSelector implements Selector{

		  int getTT(){
			return 0;
		}
		
		int i = 0;
		
		@Override
		public boolean end() {
			return (i == items.length);
		}

		@Override
		public Object current() {
			return items[i];
		}

		@Override
		public void next() {
			if(i< items.length){
				i++;
			}
		}
		
		public Sequence outer(){
			return Sequence.this;
		}
	}
	
	public Selector selector(){
		return new SequenceSelector();
	}
	


}
 
 


interface Selector{
	
	boolean end();
	
	Object current();
	
	void next();
}